# -*- coding: utf-8 -*-

# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: https://doc.scrapy.org/en/latest/topics/item-pipeline.html
import json
import re


class MyspiderPipeline(object):
    def process_item(self, item, spider):
        with open('ip.txt','a')as f:
            a=item['alive_time']
            number=re.sub(r'\D+','',a)
            print(number)
            data_time=re.sub(r'\d+','',a)
            print(data_time)
            if data_time=='天':
                number=int(number)*1440
            elif data_time=='小时':
                number = int(number) * 60
            else:
                number=int(number)

            if item['http_or_https']=='HTTP':
                item['http_or_https']='http'
            else:
                item['http_or_https'] = 'https'


            if number>=14400:
                print(number)
                print(item)
                json.dump(item,f,ensure_ascii=False,indent=2)














